/*


	Remote Control Functions

*/


void RC_Control(int speed);

int LastState=0;
#define	newstatedelay	450

void RC_Control(int speed)
{

	switch (scan_usart1())
			{
				case 'w': 
							goforward(speed); 	
							if (LastState!=0)
								_delay_ms(newstatedelay);
							LastState=0;
							break;
				case 's': 
							gobackward(speed); 	
							if (LastState!=1)
								_delay_ms(newstatedelay);
							LastState=1;
							break;
				case 'a': 
							goleft(speed);				 	
							if (LastState!=2)
								_delay_ms(newstatedelay);
							LastState=2;
							break;
				case 'd': 
							goright(speed);		
							if (LastState!=3)
								_delay_ms(newstatedelay);
							LastState=3;
							break;
				default: 
							stop();		
							LastState=4;						
							break;
			}
			_delay_ms(50);  //need this pause or else robot will jump weirdly due to PC keyboard not repeating
							//characters until key is pressed down for a little bit

}
